#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Termstructures/Volatility/Optionlet/OptionletStripper.h>
#pragma unmanaged 
#include <ql\termstructures\volatility\optionlet\optionletstripper1.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL::Math;
using namespace Cephei::QL::Termstructures::Volatility::Capfloor;
using namespace Cephei::QL::Indexes;
using namespace Cephei::QL::Times;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures { namespace Volatility { namespace Optionlet {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IOptionletStripper1
	public ref class COptionletStripper1  : 
            public COptionletStripper,
            public Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletStripper1
	{
	protected: 
		boost::shared_ptr<QuantLib::OptionletStripper1>* _ppOptionletStripper1;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::OptionletStripper1>* _phOptionletStripper1;
#endif
		Object^ _OptionletStripper1Owner;     // reference to object that manages the storage for this object
	internal:
		COptionletStripper1 (Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^ prm1, Cephei::QL::Indexes::IIborIndex^ index, Microsoft::FSharp::Core::FSharpOption<Double>^ switchStrikes, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy, Microsoft::FSharp::Core::FSharpOption<UInt32>^ maxIter);
        COptionletStripper1 (boost::shared_ptr<QuantLib::OptionletStripper1>& childNative, Object^ owner);
        COptionletStripper1 (QuantLib::OptionletStripper1& childNative, Object^ owner);
        COptionletStripper1 (COptionletStripper1^ copy);
        COptionletStripper1 (PLATFORM::Type^ t);
#ifdef STRUCT
        COptionletStripper1 (QuantLib::OptionletStripper1 childNative);
#endif       
#ifdef HANDLE
		COptionletStripper1 (QuantLib::Handle<QuantLib::OptionletStripper1>& childNative, Object^ owner);
		COptionletStripper1 (QuantLib::Handle<QuantLib::OptionletStripper1> childNative);
#endif
		virtual ~COptionletStripper1 ();
		!COptionletStripper1 ();

	internal:
		QuantLib::OptionletStripper1& GetReference ();
		boost::shared_ptr<QuantLib::OptionletStripper1>& GetShared ();
		QuantLib::OptionletStripper1* GetPointer ();
        void SetOptionletStripper1 (boost::shared_ptr<QuantLib::OptionletStripper1> native)
        {
            if (_ppOptionletStripper1 != NULL)
                delete _ppOptionletStripper1;
            _ppOptionletStripper1 = new boost::shared_ptr<QuantLib::OptionletStripper1> (native);
            SetOptionletStripper (boost::dynamic_pointer_cast<QuantLib::OptionletStripper> (*_ppOptionletStripper1));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::OptionletStripper1>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Cephei::QL::Math::IMatrix^ CapFloorPrices 
        {
		    virtual Cephei::QL::Math::IMatrix^ get () ;
        }
        property Cephei::QL::Math::IMatrix^ CapFloorVolatilities 
        {
		    virtual Cephei::QL::Math::IMatrix^ get () ;
        }
        property Cephei::QL::Math::IMatrix^ OptionletPrices 
        {
		    virtual Cephei::QL::Math::IMatrix^ get () ;
        }
        property Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletStripper1^ PerformCalculations 
        {
		    virtual Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletStripper1^ get () ;
        }
        property Double SwitchStrike 
        {
		    virtual Double get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletStripper1^>::typeid)]
	[FactoryFor(Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletStripper1::typeid)]
	[FactoryFor(Cephei::QL::Termstructures::Volatility::Optionlet::IOptionletStripper1_Factory::typeid)]
	public ref class COptionletStripper1_Factory sealed : public IOptionletStripper1_Factory
	{
	public:
        virtual IOptionletStripper1^ Create (Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^ prm1, Cephei::QL::Indexes::IIborIndex^ index, Microsoft::FSharp::Core::FSharpOption<Double>^ switchStrikes, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy, Microsoft::FSharp::Core::FSharpOption<UInt32>^ maxIter);
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures*/ } /*Volatility*/ } /*Optionlet */}
